<!--
 * @Author: sunli
 * @Date: 2024-02-21 19:18:47
 * @LastEditors: sunli
 * @LastEditTime: 2024-04-26 15:56:27
 * @FilePath: /debug/test_html/运行时异常.html
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>test-2</title>
</head>
<body>
  <h2>运行时——测试</h2>
  <script src="./lib/debugger.js"></script>
  <script>
    window.debugger('1708513389354-test2')
  </script>

  <div>
    <span>SyntaxError</span>
    <button onclick="addErr('SyntaxError')">测试</button>
  </div>
  <div>
    <span>TypeError</span>
    <button onclick="addErr('TypeError')">测试</button>
  </div>
  <div>
    <span>ReferenceError</span>
    <button onclick="addErr('ReferenceError')">测试</button>
  </div>
  <div>
    <span>RangeError</span>
    <button onclick="addErr('RangeError')">测试</button>
  </div>
  <script>
    const addErr = (type) => {
      if (type === 'SyntaxError') {
        throw SyntaxError('语法错误')
      }
      if (type === 'TypeError') {
        throw TypeError('值不是所期待的类型')
      }
      if (type === 'ReferenceError') {
        throw ReferenceError('引用未声明的变量')
      }
      if (type === 'RangeError') {
        throw RangeError('当一个值不在其所允许的范围或者集合中')
      }
    }
  </script>
</body>
</html>